#include <bits/stdc++.h>
using namespace std;
int main() {
	int T;
	cin >> T;
	while(T--) {
		string a,b;
		cin >> a >> b;
		if(a.size() < b.size()) swap(a,b);
		if(a.size() - b.size() > 1) {
			cout << "not similar" << endl;
			continue;
		}
		if(a.size() - b.size() == 1) {
			int ans = 0,f = 0;
			for(int i = 0;i < b.size(); i++) {
				if(a[i+ans] != b[i]) ans = 1;
				if(ans && a[i+ans] != b[i]) {
					cout << "not similar" << endl;
					f=1;
					break;
				}
			}
			if(f==0) cout << "similar" << endl;
		}
		if(a.size() == b.size()) {
			int sum = 0;
			for(int i = 0;i < a.size(); i++) {
				if(a[i] != b[i]) sum++;
			}
			if(sum <= 1) cout << "similar" << endl;
			else cout << "not similar" << endl;
		}
	}
	return 0;
}

